package net.entelijan.cobean.examples.showcase.config.text;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;

import net.entelijan.cobean.examples.util.ExamplesUtil;
import net.entelijan.scf.DefaultShowcasePanel;
import net.miginfocom.swing.MigLayout;

public class ConfigMultiFailureTextPanel extends DefaultShowcasePanel {

	private static final long serialVersionUID = 1L;

	private JTextField titleTextField;
	private JTextField titleFailureTextField;

	private JTextField subtitleTextField;
	private JTextField subtitleFailureTextField;

	private JTextField yearTextField;
	private JTextField yearFailureTextField;

	private JTextField authorNameTextField;
	private JTextField authorNameFailureTextField;

	private JTextField authorBirthdayTextField;
	private JTextField authorBirthdayFailureTextField;

	private JButton showModelButton = new JButton("Show Model");

	private JButton resetButton = new JButton("Reset");

	private JButton defaultValuesButton = new JButton("Default Values");

	public ConfigMultiFailureTextPanel() {
		super();
		
		titleTextField = new JTextField();
		titleFailureTextField = createFailureTextField();
		subtitleTextField = new JTextField();
		subtitleFailureTextField = createFailureTextField();
		yearTextField = new JTextField();
		yearFailureTextField = createFailureTextField();

		authorNameTextField = new JTextField();
		authorNameFailureTextField = createFailureTextField();
		authorBirthdayTextField = new JTextField();
		authorBirthdayFailureTextField = createFailureTextField();
		
		setLayout(new MigLayout());
		
		add(new JLabel(""), "w 100:100:100");
		
		add(new JSeparator(), "span 3, wrap, grow");
		add(new JLabel(""), "");
		add(createBoldLabel("Book"), "wrap");
		add(new JLabel("Title"), "");
		add(titleTextField, "w max, grow");
		add(titleFailureTextField, "w 300:300:300, wrap");
		add(new JLabel("Subtitle"), "");
		add(subtitleTextField, "w max, grow");
		add(subtitleFailureTextField, "w 300:300:300, wrap");
		add(new JLabel("Year"), "");
		add(yearTextField, "w max, grow");
		add(yearFailureTextField, "w 300:300:300, wrap");
		
		add(new JSeparator(), "span 3, wrap, grow");
		add(new JLabel(""), "");
		add(createBoldLabel("Author"), "wrap");
		add(new JLabel("Name"), "");
		add(authorNameTextField, "w max, grow");
		add(authorNameFailureTextField, "w 300:300:300, wrap");
		add(new JLabel("Birthday"), "");
		add(authorBirthdayTextField, "w max, grow");
		add(authorBirthdayFailureTextField, "w 300:300:300, wrap");

		add(new JPanel(), "h max, w max, span 3, wrap");

		add(ExamplesUtil.createButtonsPanel(150, this.showModelButton,
				this.resetButton, this.defaultValuesButton), "span 3");

	}

	private JLabel createBoldLabel(String text) {
		JLabel re = new JLabel(text);
		re.setFont(re.getFont().deriveFont(Font.BOLD));
		return re;
	}

	private JTextField createFailureTextField() {
		JTextField re = new JTextField();
		re.setForeground(Color.RED);
		re.setEditable(false);
		re.setFocusable(false);
		return re;
	}

	public JTextField getTitleTextField() {
		return titleTextField;
	}

	public void setTitleTextField(JTextField titleTextField) {
		this.titleTextField = titleTextField;
	}

	public JTextField getSubtitleTextField() {
		return subtitleTextField;
	}

	public void setSubtitleTextField(JTextField subtitleTextField) {
		this.subtitleTextField = subtitleTextField;
	}

	public JTextField getYearTextField() {
		return yearTextField;
	}

	public void setYearTextField(JTextField yearTextField) {
		this.yearTextField = yearTextField;
	}

	public JButton getShowModelButton() {
		return showModelButton;
	}

	public void setShowModelButton(JButton showModelButton) {
		this.showModelButton = showModelButton;
	}

	public JButton getResetButton() {
		return resetButton;
	}

	public void setResetButton(JButton resetButton) {
		this.resetButton = resetButton;
	}

	public void setDefaultValuesButton(JButton defaultValuesButton) {
		this.defaultValuesButton = defaultValuesButton;
	}

	public JButton getDefaultValuesButton() {
		return defaultValuesButton;
	}

	public JTextField getAuthorNameTextField() {
		return authorNameTextField;
	}

	public void setAuthorNameTextField(JTextField authorNameTextField) {
		this.authorNameTextField = authorNameTextField;
	}

	public JTextField getAuthorBirthdayTextField() {
		return authorBirthdayTextField;
	}

	public void setAuthorBirthdayTextField(JTextField authorBirthdayTextField) {
		this.authorBirthdayTextField = authorBirthdayTextField;
	}

	public JTextField getTitleFailureTextField() {
		return titleFailureTextField;
	}

	public void setTitleFailureTextField(JTextField titleFailureTextField) {
		this.titleFailureTextField = titleFailureTextField;
	}

	public JTextField getSubtitleFailureTextField() {
		return subtitleFailureTextField;
	}

	public void setSubtitleFailureTextField(JTextField subtitleFailureTextField) {
		this.subtitleFailureTextField = subtitleFailureTextField;
	}

	public JTextField getYearFailureTextField() {
		return yearFailureTextField;
	}

	public void setYearFailureTextField(JTextField yearFailureTextField) {
		this.yearFailureTextField = yearFailureTextField;
	}

	public JTextField getAuthorNameFailureTextField() {
		return authorNameFailureTextField;
	}

	public void setAuthorNameFailureTextField(JTextField authorNameFailureTextField) {
		this.authorNameFailureTextField = authorNameFailureTextField;
	}

	public JTextField getAuthorBirthdayFailureTextField() {
		return authorBirthdayFailureTextField;
	}

	public void setAuthorBirthdayFailureTextField(
			JTextField authorBirthdayFailureTextField) {
		this.authorBirthdayFailureTextField = authorBirthdayFailureTextField;
	}

}
